package longcaisuyun.longcai.com.yiliubabalongcaisuyun;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zcx.helper.http.AsyCallBack;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.net.PostShangpin_4;
import longcaisuyun.longcai.com.suyunbean.ShopBean;


public class ShangPin_4 extends Activity {

    TextView textView5;
    String title;
    String id;


    ShangPin_4Adapter s;
    GridView gridView;

    List<ShopBean> list = new ArrayList<ShopBean>();
    LinearLayout  fanhui;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shang_pin_4);
        View view = getWindow().getDecorView();
        MyApplication.ScaleScreenHelper.loadView((ViewGroup) view);
        textView5 = (TextView) findViewById(R.id.textView5);
        title = getIntent().getStringExtra("title");
        id = getIntent().getStringExtra("id");
        textView5.setText(title);
        fanhui= (LinearLayout) findViewById(R.id.fanhui);
        fanhui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        gridView = (GridView) findViewById(R.id.gridview);
        s = new ShangPin_4Adapter(ShangPin_4.this, list);
        gridView.setAdapter(s);
        MyApplication.myviewutil.startProgressDialog(ShangPin_4.this);
        HttpPost("1");
    }

    public void HttpPost(String string) {
        new PostShangpin_4(string, id, new AsyCallBack<PostShangpin_4.Info>() {
            @Override
            public void onSuccess(String toast, int type, PostShangpin_4.Info info) throws Exception {
                super.onSuccess(toast, type, info);
                if (info.message.equals("1")) {
                    for(int  j=0;j<info.list.size();j++){
                        list.add(info.list.get(j));
                    }
                    s.notifyDataSetChanged();
                }
            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
            }
        }).execute(ShangPin_4.this);
        MyApplication.myviewutil.stopProgressDialog();
    }
}
